package org.mwt.ws.webclient.business;

import org.mwt.ws.xformsservice.ServicesXDBForms;
import org.mwt.ws.xformsservice.ServicesXDBFormsService;


public class WSService implements RemoteService {
    public String CreateXForm(String stmt) throws BusinessException {
        String result = "";
        try {
            ServicesXDBFormsService service = new ServicesXDBFormsService();
            ServicesXDBForms port = service.getServicesXDBFormsPort();

            String statement = stmt;

            result = port.createXForm(statement);
            System.out.println("WS-LOG: Result = "+result);
        } catch (Exception ex) {
            throw new BusinessException("Errore nella chiamata al WS per la creazione del codice XForms", ex);
        }

       return result;
    }

    public String CreateInsertCode(String stmt) throws BusinessException {
        String result = "";
        try {
            ServicesXDBFormsService service = new ServicesXDBFormsService();
            ServicesXDBForms port = service.getServicesXDBFormsPort();

            String statement = stmt;

            result = port.createInsertCode(statement);
            System.out.println("WS-LOG: Result = "+result);
        } catch (Exception ex) {
            throw new BusinessException("Errore nella chiamata al WS per la creazione del codice per l'insert", ex);
        }

        return result;
    }

    public String CreateUpdateCode(String stmt) throws BusinessException {
        String result = "";
        try {
            ServicesXDBFormsService service = new ServicesXDBFormsService();
            ServicesXDBForms port = service.getServicesXDBFormsPort();

            String statement = stmt;

            result = port.createUpdateCode(statement);
            System.out.println("WS-LOG: Result = "+result);
        } catch (Exception ex) {
            throw new BusinessException("Errore nella chiamata al WS per la creazione del codice per l'update", ex);
        }

        return result;
    }
}
